package org.car.world.controller.shop;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
import java.net.MalformedURLException;
import java.net.URL;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.Base64;
import java.util.List;
import java.util.UUID;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.car.world.core.entily.MerchantsTable;
import org.car.world.service.MerchantsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;


import sun.misc.BASE64Decoder;


/**
 * @author Administrator
 * @ClassName: HomeController
 * @Description:主页
 * @date Nov 22, 2018
 */
@Controller
@RequestMapping("shop")
public class HomeController {

    @Autowired
    MerchantsService merchantsService;

    /**
     * @param @return 参数
     * @return String    返回类型
     * @throws
     * @Title: doindex_init
     * @Description: 访问主页
     */
    @RequestMapping("doindex")
    public String doindex_init() {
        return "shop/index";
    }


    /**
     * @param @return 参数
     * @return String    返回类型
     * @throws
     * @Title: douser_init
     * @Description: 访问我的
     */
    @RequestMapping("douser")
    public String douser_init(HttpSession session) {
		/*List<MerchantsTable>  Merchants=(List<MerchantsTable>) session.getAttribute("Merchants");
		System.err.println(Merchants.size());*/
        session.setAttribute("Merchants", (List<MerchantsTable>) session.getAttribute("Merchants"));
        return "shop/user";
    }

    /**
     * @param @return 参数
     * @return String    返回类型
     * @throws
     * @Title: doservice
     * @Description: 服务
     */
    @RequestMapping("doservice")
    public String doservice_init() {
        return "shop/service-list";
    }


    /**
     * @param @return 参数
     * @return String    返回类型
     * @throws
     * @Title: doindex_init
     * @Description: 访问文件上传
     */
    @RequestMapping("dofileupdate")
    public String dotest_init() {
        return "shop/fileupdate";
    }


    /**
     * @param @return 参数
     * @return String    返回类型
     * @throws
     * @Title: doindex_init
     * @Description: 访问我的訂單
     */
    @RequestMapping("doorder")
    public String doorder_init(@RequestParam(value = "AlltoNow", required = false, defaultValue = "0") Integer AlltoNow,
                               @RequestParam(value = "cj", required = false, defaultValue = "0") Integer cj,
                               HttpSession sesion) {
        sesion.setAttribute("AlltoNow", AlltoNow);
        sesion.setAttribute("cj", cj);
        return "shop/order";
    }

    /**
     * @param @return 参数
     * @return String    返回类型
     * @throws
     * @Title: doindex_init
     * @Description: 访问商家的评论
     */
    @RequestMapping("domypl")
    public String doorder_init(HttpSession session) {
        List<MerchantsTable> datamerlist = new ArrayList<MerchantsTable>();
        datamerlist = (List<MerchantsTable>) session.getAttribute("Merchants");
        //datamerlist = merchantsService.selectphone("17630389495");
        session.setAttribute("MerList", datamerlist);
        return "shop/myshoppl";
    }

    /**
     * @param @return 参数
     * @return String    返回类型
     * @throws
     * @Title: myshouru
     * @Description: 访问我的收入页面
     */
    @RequestMapping("myshouru")
    public String myshouru() {
        return "shop/myshopsr";
    }

}
